package gal.udc.fic.muei.tfm.dap.flipper; import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.thrift.transport.TTransportException; import org.cassandraunit.CQLDataLoader; import org.cassandraunit.dataset.cql.ClassPathCQLDataSet; import org.cassandraunit.utils.EmbeddedCassandraServerHelper; import org.junit.AfterClass; import org.junit.BeforeClass; import java.io.IOException; /** * Base class for starting/stopping Cassandra during tests. */ public class AbstractCassandraTest { @BeforeClass public static void startServer() throws InterruptedException, TTransportException, ConfigurationException, IOException { EmbeddedCassandraServerHelper.startEmbeddedCassandra(); Cluster cluster = new Cluster.Builder().addContactPoints("127.0.0.1").withPort(9142).build(); Session session = cluster.connect(); CQLDataLoader dataLoader = new CQLDataLoader(session); dataLoader.load(new ClassPathCQLDataSet("config/cql/create-tables.cql", true, "cassandra_unit_keyspace")); } @AfterClass public static void cleanupServer() { EmbeddedCassandraServerHelper.cleanEmbeddedCassandra(); } }